package pratice;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author feng
 * @Date 2022/1/1 20:17
 * 删除一个带内容的目录
 */
public class test3 {
    public static void main(String[] args) {
        String path = "D:\\IO\\A\\B\\1.text";
        File file = new File(path);
        removeDir(file);

    }

    public static void removeDir(File file) {
        //获取所有文件
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isDirectory()) {
                removeDir(file1);
            } else {
                boolean b = file1.delete();
                System.out.println(file1 + ":" + b);
            }

        }
    }
}